package com.meta.framework.copy;


import com.alibaba.fastjson.JSONObject;
import com.meta.framework.util.BeanUtil;

import java.io.Serializable;
import java.lang.reflect.Type;

/**
 * @description:
 * @auther: M.simple
 * @date: 2019/07/04 10:00
 */
public class Copyable implements Serializable {

    public <T> T transform(Class<T> clazz) {

        //return BeanUtil.copyProperties(clazz, this);
        return JSONObject.parseObject(JSONObject.toJSONString(this), clazz);
    }

    public <T> T transform(T target) {
        target = JSONObject.parseObject(JSONObject.toJSONString(this), (Type) target.getClass());
        return target;
    }

}
